<?php
    $user = $_REQUEST['user'];
    $pwd = $_REQUEST['pwd'];
    $conn = mysqli_connect('127.0.0.1','root','root','vivo');

    //注册函数 思路：注册需要先查询账号是否存在
    $sql = "SELECT * FROM `userinfo` WHERE `user`='$user'";
    $rus = mysqli_query($conn,$sql);
    $data = mysqli_fetch_assoc($rus);
    if($data==null){
        $sql = "INSERT INTO `userinfo` (`user`,`pwd`) VALUES ('$user','$pwd')";
        $rus = mysqli_query($conn,$sql);
        echo '{"code":1}';//注册成功返回1
    }else{
        echo '{"code":0}';//注册失败返回0
    }
?>